package tg.game.com.setting;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

public class SetingDemo {
	
	@SettingField(idx = 1,type = SettingFieldType.MAX)
	public int maxBet = 999;
	
	@SettingField(idx = 2,type = SettingFieldType.MIN)
	private int minBet;
	
	@SettingField(idx = 3,type = SettingFieldType.FLAG)
	private boolean flag;
	
	
	public int getMaxBet() {
		return maxBet;
	}


	public void setMaxBet(int maxBet) {
		this.maxBet = maxBet;
	}


	public int getMinBet() {
		return minBet;
	}


	public void setMinBet(int minBet) {
		this.minBet = minBet;
	}


	public boolean isFlag() {
		return flag;
	}


	public void setFlag(boolean flag) {
		this.flag = flag;
	}


	public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {
		SetingDemo   instance = new SetingDemo();
		Field[] a =  SetingDemo.class.getFields();
		try {
			int value = a[0].getInt(instance);
			System.err.println(value);
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		for (int i = 0; i < a.length; i++) {
			Field field = a[i];
			SettingField cc = field.getAnnotation(SettingField.class);
			System.err.println(""+cc.type().getName());
			
		}
		int count = 1000000000;
		int tv = 0;
		long start = System.currentTimeMillis();
		for (int i = 0; i < count; i++) {
			tv = a[0].getInt(instance);
		}
		System.err.println("field spend:"+(System.currentTimeMillis() - start));
		start = System.currentTimeMillis();
		for (int i = 0; i < count; i++) {
			tv = instance.getMaxBet();
		}
		System.err.println("spend:"+(System.currentTimeMillis() - start));
		
	}
}
